//
//  FDCarListBaseViewController.m
//  FD
//
//  Created by xiaofang wang on 2019/1/11.
//  Copyright © 2019年 ZhiYuan Network. All rights reserved.
//

#import "FDCarListBaseViewController.h"


//1-10 轮播图图片比例3:2
#define  kLunBoToViewHeight (SCREEN_WIDTH * 2 / 3)

static float kLeftTableViewWidth = 80.f;

@interface FDCarListBaseViewController ()<UITableViewDelegate, UITableViewDataSource,
ShopCartViewDelegate,
ShoppingCartViewDelegate>
/**轮播图*/
@property (nonatomic,  strong) WaiSongLunBoTuView *lunbotuView;

@property (nonatomic, strong) UITableView *leftTableView;
@property (nonatomic, strong) UITableView *rightTableView;
/**底部购物车view*/
@property (nonatomic, strong) ShopCartBottomView *shopCartBottomView;
/**点击购物车按钮 弹出购物车里面的内容的view 默认隐藏 点击购物车按钮显示*/
@property (nonatomic, strong) ShoppingCartView *shopcartView;

/**大数据源*/
@property (nonatomic,  strong) NSMutableArray *bigArr;

/**10-25购物车视图删除还是加载 用于标记是否显示购物车页面*/
@property (assign, nonatomic) BOOL isShopping;

/**11-15定义一个数组用于标记购物车中是否有数据,
 有数据才可以进行下一步
 */
@property (nonatomic, strong) NSArray *shopcartListArr;
@end

@implementation FDCarListBaseViewController
{
    NSInteger _selectIndex;
    BOOL _isScrollDown;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor]; //修改导航条颜色
    
    [self.view addSubview:self.lunbotuView];
    
    _selectIndex = 0;
    _isScrollDown = YES;
    
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars = NO;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self.view addSubview:self.leftTableView];
    [self.view addSubview:self.rightTableView];
    
    //取消多余格子
    self.leftTableView.tableFooterView = [UIView new];
    self.rightTableView.tableFooterView = [UIView new];
    
    [self.leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]
                                    animated:YES
                              scrollPosition:UITableViewScrollPositionNone];
    
    
    
    //10-15 底部购物车view
    [self.view addSubview:self.shopCartBottomView];
    
    //请求数据
    [self loadWaiSongDianCanData];
    
    //12-31请求轮播图列表数据
    [self requestWhirligigList];
    
    //注册通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isSlecte) name:@"FootView" object:nil];
    
    FDWeakSelf;
    //11-10获取营业时间
    [YingYeShiJianKeFuDianHuaHelper obtainYingYeShiJianComplectionBlock:^(NSString * _Nonnull active, NSString * _Nonnull quiet) {
        [weakSelf.shopCartBottomView updateYingYeShiJianBegin:active end:quiet];
    }];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    //移除购物车view 解决bug
    [self.shopcartView removeSubView:self];
    
    //10-25 不好处理 已进来就请求购物车数据，并计算底部购物出金额
    [self requestObtainCartList]; //请求购物车数据
}

- (void)isSlecte {
    _isShopping = NO;
}

- (void)backAction:(UIButton *)btn {
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - Getters

- (WaiSongLunBoTuView *)lunbotuView {
    if (!_lunbotuView) {
        CGRect tempFrame = self.view.bounds;
        //轮播图图片比例 3:2
        tempFrame.size.height = kLunBoToViewHeight;
        _lunbotuView = [[WaiSongLunBoTuView alloc] initWithFrame:tempFrame];
        
        //12-31点击轮播图跳转
        FDWeakSelf;
        _lunbotuView.clickWhirligigBlock = ^(NSString *resource) {
            FDWebViewController *whirligigWebViewVC = [[FDWebViewController alloc] init];
            whirligigWebViewVC.resource = resource;
            [weakSelf.navigationController pushViewController:whirligigWebViewVC animated:YES];
        };
    }
    return _lunbotuView;
}


- (UITableView *)leftTableView {
    if (!_leftTableView)
    {
        //高度
        //        CGFloat h = SCREEN_HEIGHT - 50-FD_NavH-FD_TabbarSafeBottomMargin;
        //高度:不要减导航的高度
        CGFloat h = SCREEN_HEIGHT - kLunBoToViewHeight - 50 - FD_TabbarSafeBottomMargin;
        
        _leftTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kLunBoToViewHeight, kLeftTableViewWidth, h)]; //iphoneX
        _leftTableView.delegate = self;
        _leftTableView.dataSource = self;
        _leftTableView.rowHeight = 55;
        _leftTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        _leftTableView.tableFooterView = [UIView new];
        _leftTableView.showsVerticalScrollIndicator = NO;
        _leftTableView.separatorColor = [UIColor clearColor];
        [_leftTableView registerClass:[LeftTableViewCell class] forCellReuseIdentifier:kCellIdentifier_Left];
        _leftTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _leftTableView;
}

- (UITableView *)rightTableView {
    if (!_rightTableView)
    {
        //高度:不要减导航的高度
        CGFloat h = SCREEN_HEIGHT - kLunBoToViewHeight - 50 - FD_TabbarSafeBottomMargin;
        
        FDLog(@"rect的高度:%@",NSStringFromCGRect(self.view.frame));
        FDLog(@"高度:%f",h);
        
        //宽度要减去左边的view
        //        SCREEN_HEIGHT-kLunBoToViewHeight
        _rightTableView = [[UITableView alloc] initWithFrame:CGRectMake(kLeftTableViewWidth, kLunBoToViewHeight, SCREEN_WIDTH-kLeftTableViewWidth, h)];
        _rightTableView.delegate = self;
        _rightTableView.dataSource = self;
        _rightTableView.rowHeight = 80;
        _rightTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        _rightTableView.showsVerticalScrollIndicator = NO;
        [_rightTableView registerClass:[RightTableViewCell class] forCellReuseIdentifier:kCellIdentifier_Right];
    }
    return _rightTableView;
}
//!!!!:底部购物车view 固定高度为:50
- (ShopCartBottomView *)shopCartBottomView {
    if (!_shopCartBottomView) {
        //view的高度
        CGFloat sh = self.view.bounds.size.height;
        NSLog(@"1111view的bounds:%@",NSStringFromCGRect(self.view.bounds));
        NSLog(@"2222屏幕的宽高：%f--%f",SCREEN_WIDTH,SCREEN_HEIGHT);
        
        //适配iphoneX:要减去顶部导航栏的高度:(-导航条的高度 - 底部状态栏目的高度34)
        CGFloat y = sh - 50-FD_NavH-FD_TabbarSafeBottomMargin;
        _shopCartBottomView = [[ShopCartBottomView alloc] initWithFrame:CGRectMake(0, y, SCREEN_WIDTH, 50)];
        //设置的代理
        _shopCartBottomView.delegate = self;
    }
    return _shopCartBottomView;
}

- (NSMutableArray *)bigArr {
    if (!_bigArr) {
        _bigArr = [NSMutableArray array];
    }
    return _bigArr;
}

#pragma mark - TableView DataSource Delegate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (_leftTableView == tableView)
    {
        return 1;
    }
    else
    {
        return self.bigArr.count;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (_leftTableView == tableView)
    {
        return self.bigArr.count;
    }
    else
    {
        //取出大model
        WaiSongBigModel *bigModel = self.bigArr[section];
        return bigModel.goods.count;     //返回大model里面的数组的个数
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (_leftTableView == tableView)
    {
        LeftTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_Left forIndexPath:indexPath];
        
        WaiSongBigModel *bigModel = self.bigArr[indexPath.row];
        cell.nameLb.text= bigModel.name;
        return cell;
    }
    else
    {
        RightTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_Right forIndexPath:indexPath];
        //返回右边的cell
        WaiSongBigModel *bigModel = self.bigArr[indexPath.section];
        WaiSongDetailModel *smallModel = bigModel.goods[indexPath.row];
        
        cell.detailModel = smallModel;
        
        //事件回调:添加都购物车
        cell.clickAddBtnBlock = ^(NSInteger count) {
            [self requestAddCart:smallModel.goodsId quantity:@(count)];
        };
        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (_rightTableView == tableView)
    {
        return FDHeightScale(100); //100-30;
    }else {
        return 44;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (_rightTableView == tableView)
    {
        return 20;
    }
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (_rightTableView == tableView)
    {
        TableViewSectionHeaderView *sectionHeaderView = [[TableViewSectionHeaderView alloc] initWithFrame:CGRectMake(kLeftTableViewWidth, 100, SCREEN_WIDTH-kLeftTableViewWidth, 25)];
        WaiSongBigModel *bigModel = self.bigArr[section];
        sectionHeaderView.nameLb.text = bigModel.name;
        return sectionHeaderView;
    }
    return nil;
}

// TableView分区标题即将展示
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(nonnull UIView *)view forSection:(NSInteger)section
{
    // 当前的tableView是RightTableView，RightTableView滚动的方向向上，RightTableView是用户拖拽而产生滚动的（（主要判断RightTableView用户拖拽而滚动的，还是点击LeftTableView而滚动的）
    if ((_rightTableView == tableView)
        && !_isScrollDown
        && (_rightTableView.dragging || _rightTableView.decelerating))
    {
        [self selectRowAtIndexPath:section];
    }
}

// TableView分区标题展示结束
- (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section
{
    // 当前的tableView是RightTableView，RightTableView滚动的方向向下，RightTableView是用户拖拽而产生滚动的（（主要判断RightTableView用户拖拽而滚动的，还是点击LeftTableView而滚动的）
    if ((_rightTableView == tableView)
        && _isScrollDown
        && (_rightTableView.dragging || _rightTableView.decelerating))
    {
        [self selectRowAtIndexPath:section + 1];
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
    if (_leftTableView == tableView)
    {
        _selectIndex = indexPath.row;
        [_rightTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:_selectIndex] atScrollPosition:UITableViewScrollPositionTop animated:YES];
        [_leftTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:_selectIndex inSection:0]
                              atScrollPosition:UITableViewScrollPositionTop
                                      animated:YES];
    }else { //如果点击的是右边的按钮， 跳转到商品详情页面
        //取出对应的Model、
        WaiSongBigModel *bigModel = self.bigArr[indexPath.section];
        WaiSongDetailModel *detailModel = bigModel.goods[indexPath.row];
        
        GoodsDetailViewController *detailVC = [[GoodsDetailViewController alloc] init];
        detailVC.goodsId = detailModel.goodsId;
        [self.navigationController pushViewController:detailVC animated:YES];
    }
}

// 当拖动右边TableView的时候，处理左边TableView
- (void)selectRowAtIndexPath:(NSInteger)index
{
    [_leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]
                                animated:YES
                          scrollPosition:UITableViewScrollPositionTop];
}

#pragma mark - UISrcollViewDelegate
// 标记一下RightTableView的滚动方向，是向上还是向下
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    static CGFloat lastOffsetY = 0;
    
    UITableView *tableView = (UITableView *) scrollView;
    if (_rightTableView == tableView)
    {
        _isScrollDown = lastOffsetY < scrollView.contentOffset.y;
        lastOffsetY = scrollView.contentOffset.y;
    }
}


#pragma mark - ShopCartViewDelegate
//!!!!:点击了购物按钮，显示购物车
- (void)shopcartViewDidClickCartBtn:(UIButton *)btn {
    [self requestObtainCartList];
    
    if (!_isShopping)
    {
        self.shopcartView=[[ShoppingCartView alloc]init];
        self.shopcartView.frame =CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH,SCREEN_HEIGHT-FD_NavH-FD_TabbarSafeBottomMargin);
        self.shopcartView.delegate = self; //设置代理
        
        //蒙版：蒙版为什么不放在里面呢？
        UIView *bgView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH,SCREEN_HEIGHT-50-FD_NavH-FD_TabbarSafeBottomMargin)];
        //        bgView.alpha = .7;
        bgView.tag = 111;
        //        bgView.backgroundColor =[UIColor lightGrayColor];
        bgView.backgroundColor = [UIColor rb_colorHex:0x000000 alpha:0.5];
        
        [self.view addSubview:bgView];
        
        //显示购物车
        [self.shopcartView addShoppingCartView:self];
        
        [UIView animateWithDuration:.3 animations:^{
            //适配iphoneX
            self.shopcartView.frame =CGRectMake(0, 0, SCREEN_WIDTH,SCREEN_HEIGHT-50-FD_NavH-FD_TabbarSafeBottomMargin);
        } completion:^(BOOL finished) {
        }];
    }
    else{
        [self.shopcartView removeSubView:self];
    }
    _isShopping = !_isShopping;
}

//!!!!:点击结算
- (void)shopcartViewDidClickJieSuanBtnAction:(UIButton *)btn {
    FDLog(@"点击结算");
    //跳转确认订单页面
    //如果购物车中无数据就，不允许跳转
    if (!self.shopcartListArr.count) {
        //国际化
        NSString *noGoods = NSLocalizedString(Home_ShopCartNoGoods, @"购物车暂无商品");
        [JRToast showWithText:noGoods];
        return;
    }
    
//    develop log 1-11
//    WSSureOrderViewController *sureorderVC = [[WSSureOrderViewController alloc] init];
//    [self.navigationController pushViewController:sureorderVC animated:YES];
    
    if (self.clickJieSuanActionBlock) {
        self.clickJieSuanActionBlock();
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - 自定义导航条
// 创建“导航栏”
- (void)createNav{
    // 在主线程异步加载，使下面的方法最后执行，防止其他的控件挡住了导航栏
    dispatch_async(dispatch_get_main_queue(), ^{
        //替换系统的返回箭头
        //        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"返回箭头.png"] style:(UIBarButtonItemStylePlain) target:self action:@selector(backAction:)];
        
        //==========替换中间的按钮================
        //        WaiSongNavTitleView *titleView = [[WaiSongNavTitleView alloc] initWithFrame:CGRectMake(0, 0, 150, 50)];
        //        self.navigationItem.titleView =titleView;
        
        //=========右边的按钮===========
        UIButton *rightMyKaQuanBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [rightMyKaQuanBtn setTitle:@"我的卡券" forState:(UIControlStateNormal)];
        [rightMyKaQuanBtn setTitleColor:[UIColor redColor] forState:(UIControlStateNormal)];
        [rightMyKaQuanBtn addTarget:self action:@selector(clickRightMyKaQuanAction:) forControlEvents:(UIControlEventTouchUpInside)];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightMyKaQuanBtn];
    });
}

// 点击了 导航啦栏右侧的我的卡券
- (void)clickRightMyKaQuanAction:(UIButton *)btn {
    MyKaQuanViewController *myKaQuanVC = [[MyKaQuanViewController alloc] init];
    [self.navigationController pushViewController:myKaQuanVC animated:YES];
}


#pragma mark - 请求数据
/**请求外送点餐数据*/
- (void)loadWaiSongDianCanData {
    
    [MBProgressHUD fd_showHUDToView:self.view];//菊花
    [FDHttpAPi requestSYGoodsListWithGoodsClassifyId:self.shangPinLeiMuId SuccessBlock:^(id responseObjc) {
        [MBProgressHUD fd_hideHUDFromView:self.view]; //移除菊花
        NSString *event = responseObjc[@"event"];
        if ([event isEqualToString:@"SUCCESS"]) { //请求成功解析数据
            NSArray *dataArr = responseObjc[@"data"];
            
            //将需要的数据转换为model
            [self assembleDataWithArr:dataArr];
            
            //回到主线程刷新数据
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.leftTableView reloadData];
                [self.rightTableView reloadData];
                
                //12-31默认第一个选中 请求到数据之后调用。
                [self.leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionNone];
            });
            
        }else { //toast
            [JRToast showWithText:responseObjc[@"describe"]];
        }
    } failBlock:^(NSError *error) {
        FDLog(@"%@",[error localizedDescription]);
        [MBProgressHUD fd_hideHUDFromView:self.view]; //移除菊花
    }];
}

/**重新组装数据*/
- (void)assembleDataWithArr:(NSArray *)arr {
    
    if(!arr.count) return; //如果数组为空，直接返回
    
    for (NSDictionary *dic1 in arr) {
        
        NSMutableArray *goodsArrM = [NSMutableArray array];
        
        NSArray *goods = dic1[@"goodsList"];
        //将dic 转换为model
        for (NSDictionary *innerDic in goods) {
            WaiSongDetailModel *detailM = [WaiSongDetailModel mj_objectWithKeyValues:innerDic];
            [goodsArrM addObject:detailM];
        }
        
        //重新组装大dic
        NSMutableDictionary *bigDic = [NSMutableDictionary dictionary];
        [bigDic setValue:dic1[@"name"] forKey:@"name"];
        [bigDic setValue:goodsArrM forKey:@"goods"];
        
        //转model
        WaiSongBigModel *bigM = [WaiSongBigModel mj_objectWithKeyValues:bigDic];
        
        //装入数组
        [self.bigArr addObject:bigM];
    }
}

//!!!!:添加到购物车(非套餐商品) :商品id， 数量
- (void)requestAddCart:(NSNumber *)goodId quantity:(NSNumber *)quantity {
    [FDHttpAPi requestSYUserCartAddWithGoodId:goodId quantity:quantity successBlock:^(id responseObjc) {
        NSString *event = responseObjc[@"event"];
        if ([event isEqualToString:@"SUCCESS"]) { //添加成功
            
            [JRToast showWithText:NSLocalizedString(ToastAddSucess, @"添加成功")];
            
            // 获取购物车列表
            [self requestObtainCartList];
            
        }else { //toast
            [JRToast showWithText:responseObjc[@"describe"]];
        }
    } failBlock:^(NSError *error) {
        FDLog(@"%@",[error localizedDescription]);
    }];
}
//!!!!:获取购物车数据
- (void)requestObtainCartList {
    [FDHttpAPi requestSYUserCartListSuccessBlock:^(id responseObjc) {
        
        //不做处理 直接将服务器返回的数据传过去
        NSString *event = responseObjc[@"event"];
        if ([event isEqualToString:SUCCESS]) { //请求成功
            NSArray *data = responseObjc[@"data"];
            
            //11-15作用:记录购物车数据，用于判断“去结算”按钮是否可点击
            self.shopcartListArr = [data copy];
            
            //11-2解析数据计算总价总价
            CGFloat totalPrice = [self resolvingCartListAndCountTotalPriceWithArr:data];
            //重新赋值
            [self.shopCartBottomView updateshopcartBottomViewTotalPrice:totalPrice];
        }else {
            [JRToast showWithText:responseObjc[describe]];
        }
    } failBlock:^(NSError *error) {
        FDLog(@"%@",error);
    }];
}
//!!!!:修改购物车数量
- (void)requestUpdateCartQuantity:(NSNumber *)quantity cartId:(NSNumber *)cartId {
    [FDHttpAPi requestSYUserCartUpdateQuantity:quantity cartId:cartId successBlock:^(id responseObjc) {
        //暂时处理处理方式:不做处理 请求失败就修改数据 10-25
        NSString *event = responseObjc[@"event"];
        if ([event isEqualToString:SUCCESS]) {
            
            [FDSystemTool fd_virbrate]; //11-26振动
        }else {
            [JRToast showWithText:responseObjc[describe]];
        }
        
    } failBlock:^(NSError *error) {
        FDLog(@"%@",[error localizedDescription]);
    }];
}
//!!!!:移除购物车
- (void)requestCartRemoveCartId:(NSNumber *)cartId {
    [FDHttpAPi requestSYUserCartRemoveCartId:cartId successBlock:^(id responseObjc) {
        
        NSString *event = responseObjc[@"event"];
        if ([event isEqualToString:SUCCESS]) {
            
            //刷新数据:此时 ShoppingCartView 对象是存在的可以调接口然后 在进行刷新
            [self requestObtainCartList];
        }else {
            [JRToast showWithText:responseObjc[describe]];
        }
    } failBlock:^(NSError *error) {
        FDLog(@"%@",[error localizedDescription]);
    }];
}

//11-2解析数据计算总价总价
- (CGFloat)resolvingCartListAndCountTotalPriceWithArr:(NSArray *)arr
{
    
    NSMutableArray *newArrM  = [NSMutableArray array];
    //转模型
    for (NSDictionary *dic in arr) {
        NewShopcartModel *m = [NewShopcartModel mj_objectWithKeyValues:dic];
        [newArrM addObject:m];
    }
    
    //遍历计算总价
    CGFloat sumPrice = 0.0;
    for (NewShopcartModel *model in newArrM) {
        sumPrice += model.totalcurrentPrice * [model.quantity floatValue];
    }
    return sumPrice;
}


/**12-31 请求商品列表轮播图数据*/
- (void)requestWhirligigList {
    [FDHttpAPi requestGoodsListWhirligigSuccessBlock:^(id responseObjc) {
        NSString *event = responseObjc[@"event"];
        if ([event isEqualToString:SUCCESS]) {
            
            NSMutableArray *tempArrM = @[].mutableCopy;
            
            NSArray *dataArr = responseObjc[@"data"];
            for (NSDictionary *dic in dataArr) {
                WaiSongWhirligigModel *whirligigModel = [WaiSongWhirligigModel mj_objectWithKeyValues:dic];
                
                [tempArrM addObject:whirligigModel];
            }
            
            [self.lunbotuView updateWhirligArrWithModelArr:[tempArrM copy]];
            
        }else {
            FDLog(@"网络请求错误:%s",__FUNCTION__);
        }
    } failBlock:^(NSError *error) {
        FDLog(@"%s--%@",__FUNCTION__,error);
    }];
}


#pragma mark - 11-13 ShoppingCartViewDelegate
- (void)shoppingCartViewUpdateTotalPrice:(CGFloat)totalPrice {
    FDLog(@"%f",totalPrice);
    //更新底部购物车总金额
    [self.shopCartBottomView updateshopcartBottomViewTotalPrice:totalPrice];
}
//购物车被清空的回调
- (void)shoppingCartHaveBeClean {
    //消失
    [self.shopcartView removeSubView:self];
    
    [self requestObtainCartList]; //重新来一遍,解决底部总价不更新bug。
}

@end

